<?php defined('InShopNC') or exit('Access Invalid!');?>

<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<style>
    td.tl{
        line-height: 30px;
    }
    td.tl input{
        width:45px;
    }
    .freight_type dt{
        margin-top: 32px!important;
    }
    .freight_type dd tr:first-child td{
        border-bottom: dotted 1px #E6E6E6;
    }
    .freight_type dd tr:last-child td{
        border:none;
    }
</style>
<div class="tabmenu">
  <?php include template('layout/submenu');?>
</div>
<div class="ncsc-form-default">
    <div id="warning1" class="alert alert-error" style="display: none;"></div>
    <form id="form_setting" method="post" action="<?php echo urlShop('store_my', 'save_map_delivery');?>">
        <input type="hidden" name="map_id" value="<?php echo $output['map_delivery']['map_id']; ?>" />
        <input type="hidden" name="delivery_id" value="<?php echo $output['map_delivery']['delivery_id']; ?>" />
        <dl>
            <dt>启用门店区域配送限定<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <label for="store_decoration_switch_on" class="mr30">
                    <input id="store_decoration_switch_on" type="radio" class="radio vm mr5" name="state" value="1" <?php echo $output['map_delivery']['state'] > 0?'checked':'';?>>
                    是</label>
                <label for="store_decoration_switch_off">
                    <input id="store_decoration_switch_off" type="radio" class="radio vm mr5" name="state" value="0" <?php echo $output['map_delivery']['state'] == 0?'checked':'';?>>
                    否</label>
                <!--<p class="hint">选择是否使用店铺装修模板；<br/>
                    如选择“是”，店铺首页背景、头部、导航以及上方区域都将根据店铺装修模板所设置的内容进行显示；<br/>
                    如选择“否”根据 <a href="index.php?act=store_setting&op=theme">“店铺主题”</a> 所选中的系统预设值风格进行显示。</p>-->
            </dd>
        </dl>
        <dl>
            <dt>门店地址<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <label id="address_info">
                    <span id="address_info_span"><?php echo $output['map_delivery']['address_info']; ?></span>
                    <input type="hidden" name="name_info" value="<?php echo $output['map_delivery']['name_info']; ?>" />
                    <input type="hidden" name="address_info" value="<?php echo $output['map_delivery']['address_info']; ?>" />
                    <input type="hidden" name="phone_info" value="<?php echo $output['map_delivery']['phone_info']; ?>" />
                    <textarea name="bus_info" style="display: none;"><?php echo $output['map_delivery']['bus_info']; ?></textarea>
                    <input type="hidden" name="baidu_lng" value="<?php echo $output['map_delivery']['baidu_lng']; ?>">
                    <input type="hidden" name="baidu_lat" value="<?php echo $output['map_delivery']['baidu_lat']; ?>">
                    <input type="hidden" name="baidu_province" value="<?php echo $output['map_delivery']['baidu_province']; ?>">
                    <input type="hidden" name="baidu_city" value="<?php echo $output['map_delivery']['baidu_city']; ?>">
                    <input type="hidden" name="baidu_district" value="<?php echo $output['map_delivery']['baidu_district']; ?>">
                    <input type="hidden" name="baidu_street" value="<?php echo $output['map_delivery']['baidu_street']; ?>">
                </label>
                <label class="nscs-table-handle">
                    <span><a href="javascript:void(0)" class="btn-mint" nc_type="dialog" dialog_title="<?php echo $lang['nc_edit'];?>" dialog_id="map_edit" dialog_width="480" uri="index.php?act=store_my&op=edit_map&map_id=<?php echo $output['map_delivery']['map_id']; ?>"><i class="icon-edit"></i><p><?php echo $lang['nc_edit'];?></p></a></span>
                </label>
            </dd>
        </dl>
        <dl>
            <dt>门店派送时段<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <input id="start_time" class="text w70" type="text" name="delivery_start_time" value="<?php echo $output['map_delivery']['delivery_start_time']; ?>" /><label class="add-on"><i class="icon-calendar"></i></label>&nbsp;&#8211;&nbsp;
                <input id="end_time" class="text w70" type="text" name="delivery_end_time" value="<?php echo $output['map_delivery']['delivery_end_time']; ?>" /><label class="add-on"><i class="icon-calendar"></i></label>
            </dd>
        </dl>
        <dl>
            <dt>派送区域<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <label id="areas_info">
                    <span><?php echo implode(' ',explode(',',$output['map_delivery']['district_name'])); ?></span>
                    <input type="hidden" name="areas" value="<?php echo $output['map_delivery']['district_id'].'|||'.$output['map_delivery']['district_name']; ?>">
                </label>
                <label class="trans-line nscs-table-handle">
                    <span>
                        <a class="btn-bluejeans" data-group="nCurNum" title="编辑运送区域" area-haspopup="true" area-controls="J_DialogArea" entype='J_EditArea' data-acc="event:enter" href="JavaScript:void(0);">
                            <i class="icon-edit"></i><p>编辑</p>
                        </a>
                    </span>
                </label>
            </dd>
        </dl>
        <dl>
            <dt>订单总价最低限价<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <input  class="text w70" type="text" name="order_floor_price" value="<?php echo $output['map_delivery']['order_floor_price']; ?>" />
            </dd>
        </dl>
        <dl class="freight_type">
            <dt>运费计算方式<?php echo $lang['nc_colon'];?></dt>
            <dd>
                <table class="ncsc-default-table" >
                    <tr class="bd-line">
                        <td>
                            <label for="is_default_<?php echo $address['address_id'];?>">
                                <input type="radio" id="is_default_1" name="freight_type" <?php if ($output['map_delivery']['freight_type'] == 1) echo 'checked';?> value="1">

                            </label>
                        </td>
                        <td class="tl">按重量增加，首KG <input type="text" name="first_weight_freight" value="<?php echo $output['map_delivery']['first_weight_freight'];?>"> 元,每增加1KG <input type="text" name="incr_freight" value="<?php echo $output['map_delivery']['incr_freight'];?>"> 元</td>
                    </tr>
                    <tr class="bd-line">
                        <td>
                            <label for="is_default_<?php echo $address['address_id'];?>">
                                <input type="radio" id="is_default_1" name="freight_type" <?php if ($output['map_delivery']['freight_type'] == 2) echo 'checked';?> value="2">
                            </label>
                        </td>
                        <td class="tl">按每订单 <input type="text" name="order_freight" value="<?php echo $output['map_delivery']['order_freight'];?>"> 元</td>
                    </tr>
                </table>
            </dd>
        </dl>
        <div class="bottom">
            <label class="submit-border">
                <input id="btn_submit" type="submit" class="submit" value="提交" />
            </label>
        </div>
    </form>
    <div id="dialog_areas" class="dialog-areas" style="display:none">
        <div class="ks-contentbox">
            <div class="title"><?php echo $lang['transport_tpl_select_area'];?><a class="ks-ext-close" href="javascript:void(0)">X</a></div>
            <form method="post">
                <ul id="J_CityList">
                    <?php require(template('seller/store_transport_area_district'));?>
                </ul>
                <div class="bottom"> <a href="javascript:void(0);" class="J_Submit ncbtn ncbtn-mint"><?php echo $lang['transport_tpl_ok'];?></a> <a href="javascript:void(0);" class="J_Cancel ncbtn"><?php echo $lang['transport_tpl_cancel'];?></a> </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script src="<?php echo SHOP_RESOURCE_SITE_URL;?>/js/transport_district.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.min.css"  />

<script type="text/javascript">
    $(document).ready(function(){

        $('#start_time').timepicker({
            controlType: 'select',
        });

        $('#end_time').timepicker({
            controlType: 'select'
        });

        jQuery.validator.addMethod("areas_rule", function(value, element) {
            return this.optional(element) || (value!='|||未添加地区');
        }, "请选择派送区域");

        $('#form_setting').validate({
            errorLabelContainer: $('#warning1'),
            invalidHandler: function(form, validator) {
                $('#warning1').show();
            },
            submitHandler:function(form){
                ajaxpost('form_setting', '', '', 'onerror');
            },
            rules : {
                address_info : {
                    required : true
                },
                delivery_start_time : {
                    required   : true
                },
                delivery_end_time : {
                    required   : true
                },
                areas : {
                    areas_rule   : true
                }
            },
            messages : {
                address_info : {
                    required : '<i class="icon-exclamation-sign"></i>门店地址不能为空'
                },
                delivery_start_time  : {
                    required   : '<i class="icon-exclamation-sign"></i>门店派送时段不能为空'
                },
                delivery_end_time : {
                    required : '<i class="icon-exclamation-sign"></i>门店派送时段不能为空'
                },
                areas  : {
                    areas_rule   : '<i class="icon-exclamation-sign"></i>请选择派送区域'
                }

            }
        });

    });
</script>